﻿using Service;
using Service.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.ServiceModel.Description;
using System.Text;
using System.Threading.Tasks;

namespace Host
{
    class Program
    {
        static void Main(string[] args)
        {
            using (ServiceHost host = new ServiceHost(typeof(PeopleService)))
            {
                host.AddServiceEndpoint(typeof(IPeopleOperator),
                new WSHttpBinding(),
                "http://localhost:9999/PeopleService");

                if (host.Description.Behaviors.Find<ServiceMetadataBehavior>() == null)
                {
                    ServiceMetadataBehavior behavior = new ServiceMetadataBehavior();
                    behavior.HttpGetEnabled = true;
                    behavior.HttpGetUrl = new Uri("http://localhost:9999/PeopleService/PeopleService/metadata");
                    host.Description.Behaviors.Add(behavior);
                }

                host.Opened += (s, e) => Console.WriteLine("Service is running, press any key to stop");
                host.Open();
                Console.Read();
            }
        }
    }
}
